package org.shiki.hrm.controller;

import org.shiki.hrm.dto.SmsDto;
import org.shiki.hrm.service.IVerifyCodeService;
import org.shiki.hrm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

	@Autowired
	private IVerifyCodeService verifyCodeService;

	@GetMapping("/imageCode/{key}")
	public AjaxResult imageCode(@PathVariable("key") String key) throws IOException {
		return verifyCodeService.createCode(key);
	}

	@PostMapping("/sendSmsCode")
	public AjaxResult sendSmsCode(@RequestBody SmsDto dto){
		return verifyCodeService.sendSmsCode(dto);
	}
}
